<?php 
/*
Template Name: view dat lich
*/
?>
<?php get_header(); ?>



<link rel='stylesheet' type='text/css' href='<?php bloginfo('template_directory'); ?>/css/reset.css' /> 
  <link rel='stylesheet' type='text/css' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/start/jquery-ui.css' />

  <link rel='stylesheet' type='text/css' href='<?php bloginfo('template_directory'); ?>/css/jquery.weekcalendar.css' />
  <link rel='stylesheet' type='text/css' href='<?php bloginfo('template_directory'); ?>/css/demo.css' />


<style type="text/css" media="screen">
  
  #demoBasic .dd-options{
    width: 935px !important;
    min-height: 650px;
  }
  #demoBasic .dd-options li{
    width: 310px !important;
    float: left !important;
  }
  #demoBasic img{
    border-radius: 5px !important;
  }
  .datlich{
    margin-top: 20px;
  }
  .active{
    background-color: #4BAF03;
  }
  .wc-cal-event .wc-title{
    background-color: #2b72d0;
  border: 1px solid #1b62c0;
  }
  #status{
     
     background-image: url('<?php bloginfo('template_directory'); ?>/images/bg-opacity.png');
    display: block;
    height: 100%;
    left: 0;
    padding-top: 25%;
    position: fixed;
    text-align: center;
    top: 0;
    width: 100%;
    z-index: 9999999999;
    font-size: 20px;
    font-weight: bold;
    display: none;
    color: #004A72;
  }
  .wc-scrollable-grid{
    height: 800px;
  }
</style>

<div id="content_nano">

      <!--banner section 
      <div id="banner_wrapp">
        <div id="banner">


          <?php //if ( get_option('chameleon_featured') == 'on' ) get_template_part('includes/featured'); ?>
        </div><!-- id="banner" -->
    
      </div><!-- id="banner_wrapp" -->


<?php //get_template_part('includes/breadcrumbs'); ?>
<?php //get_template_part('includes/top_info'); ?>
<br/>
<div id="" class="clearfix">


  <div id="left-area">
    
    <div id="gallery" class="datlich">
        <div class="gallery_category">
          <h2>Đặt lịch</h2>

          <div class="">
        
     <!-- <button type="button" id="about_button">Hướng dẫn đặt lịch</button>-->


         
          </div>
        </div>
<div id="" class="clearfix"></div>
<?php 
           

          ?>
  <div id="demoBasic">

  </div>
  <div class="message"></div>


<input type="hidden" name="val_may" id="val_may" value="">

<div id="status" style="">
  Đang xử lý ...
    <img src="<?php bloginfo('template_directory'); ?>/images/load.gif" alt="" />
   </div>

  <div id="frm_content">
    <!-- content-->
  
  </div>
  

    
  </div>



        <div id="">
           
  
  
 
  


  
        </div>
      </div>
  </div>  

  

  <?php //get_sidebar(); ?>

</div> <!-- end #content -->  

</div><!-- id="content_nano" -->
    
<?php get_footer(); ?>



<?php 


            global $current_user;
            get_currentuserinfo();
            $id_user=$current_user->ID;

$sql=@"SELECT 
wp_users.ID,
wp_users.user_login,
wp_may.*
FROM wp_user_wp_may

INNER JOIN wp_may 

ON wp_user_wp_may.id_may = wp_may.id_may

JOIN wp_users

ON wp_user_wp_may.ID = wp_users.ID

where wp_user_wp_may.ID=".$id_user;
          
          
                    $posts = $wpdb->get_results($sql);
                   $base_url=get_bloginfo('template_directory'); 
?>

<script type="text/javascript">
  jQuery(function($) {

var ddData = [
    <?php
          foreach ($posts as $may)
                    {
                      $des="Bạn có thể đặt lịch cho máy này";
                      $des=" ";
                      if($id_user!=$may->ID){
                        $des="Bạn không thể đặt lịch cho máy này";
                      }
                      echo '{
                          text: '.'"'.$may->name_may.'"'.',
                          value: '.$may->id_may.',
                          selected: false,
                          description: "'.$des.'",
                          imageSrc: '.'"'.$base_url.'/upload_may/'.$may->image_may_url.'"'.',
                      },';
                    }
          ?>
         
];




$('#demoBasic').ddslick({
    data: ddData,
    width: 300,
    imagePosition: "left",
    selectText: "Chọn máy đặt lịch",
    onSelected: function (result) {
         
        //$('#calendar').hide('slow');
        //$('#calendar').show('slow');
        $('#val_may').val(result.selectedData.value);
        $('#id_may').val(result.selectedData.value);
      //showHint(result.selectedData.value);
      //$('#loading').show();
              $.ajax({
                    type: "post",
                    url: <?php echo '"'.$base_url.'/process.php"';?>,
                    data: {id:result.selectedData.value},
                    contentType: "application/x-www-form-urlencoded",

                    beforeSend: function() {

                                 $("#status").show();

                                         },
                    success: function(responseData, textStatus, jqXHR) {
                        $("#status").hide();
                        //alert("data saved")
                        //alert(responseData);
                        $('#frm_content').html(responseData);
                        $('#loading').hide();
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        //console.log(errorThrown);
                        alert(errorThrown);
                         $('#loading').hide();
                    }
                })

     }
    
    
});




});


</script>






